package com.yanqu.road.server.cmd.wineshop;

import com.yanqu.road.pb.wineshop.WineShopProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.wineshop.WineShopModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/7/20 16:11
 */
@Cmd(code = GameProtocol.S_WINESHOP_RECEPTION, desc = "酒肆叫号")
public class WineShopReceptionCmd extends AbstractCommand {
    private boolean isOneKey;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WineShopProto.WineShopReceptionReqMsg msg = WineShopProto.WineShopReceptionReqMsg.parseFrom(packet.getBytes());
        isOneKey = msg.getIsOneKey();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        player.getModule(WineShopModule.class).offLineReception();
        WineShopProto.WineShopReceptionRespMsg.Builder respMsg = WineShopProto.WineShopReceptionRespMsg.newBuilder();
        if (isOneKey) {
            ret = player.getModule(WineShopModule.class).oneKeyReceptionBeauty(respMsg, false);
        } else {
            ret = player.getModule(WineShopModule.class).receptionBeauty();
        }
        respMsg.setRet(ret);
        player.sendPacket(ClientProtocol.U_WINESHOP_RECEPTION, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
